package beautiful.butterfly.drds.datasource.connection_contexts.spi;

//import beautiful.butterfly.drds.datasource.author.Author;
//import beautiful.butterfly.drds.datasource.author.Authors;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * 数据库连接操作
 */
// @Author(name = Authors.LI_YANG)
public final class JdbcUtils {
    public static void close(Connection connection) {
        if (connection == null) {
            throw new NullPointerException(Connection.class.getSimpleName());
        }
        try {
            connection.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void close(Statement statement) {
        if (statement == null) {
            throw new NullPointerException(Statement.class.getSimpleName());
        }
        try {
            statement.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static void close(ResultSet resultSet) {
        if (resultSet == null) {
            throw new NullPointerException(ResultSet.class.getSimpleName());
        }
        try {
            resultSet.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
